home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / comm2 / termsorc.lha / Extras / Source / gtlayout-source.lha / LT_Build.c < prev    next >
C/C++ Source or Header  |  1995-09-25  |  16KB  |  774 lines

  1. /*  GadTools layout toolkit
  2. **
  3. **  Copyright © 1993-1995 by Olaf `Olsen' Barthel
  4. **  Freely distributable.
  5. */
  6.  
  7. #include "gtlayout_global.h"
  8.  
  9. struct Window * __stdargs
  10. LT_Build(LayoutHandle *Handle,...)
  11. {
  12.     struct Window    *Result;
  13.     va_list      VarArgs;
  14.  
  15.     va_start(VarArgs,Handle);
  16.     Result = LT_BuildA(Handle,(struct TagItem *)VarArgs);
  17.     va_end(VarArgs);
  18.  
  19.     return(Result);
  20. }
  21.  
  22.  
  23. /*****************************************************************************/
  24.  
  25.  
  26. struct Window * LIBENT
  27. LT_BuildA(REG(a0) LayoutHandle *handle,REG(a1) struct TagItem *TagParams)
  28. {
  29.     LONG         left, top, width, height;
  30.     LONG         OldLeft,OldTop,OldRight,OldBottom;
  31.     struct IBox     newBounds;
  32.     struct Menu    *menu        = NULL;
  33.     struct TagItem    *item;
  34.     LONG         placeLeft;
  35.     LONG         placeTop;
  36.     struct IBox     zoomBox;
  37.     struct IBox    *zoom;
  38.     LONG         i;
  39.     struct TextFont *font;
  40.     struct TagItem    *NewTags = NULL,*Tags;
  41.     BOOL          BlockParent = handle -> BlockParent,
  42.              SmartZoom = FALSE;
  43.     BOOL         MakeVisible = FALSE;
  44.     struct Window    *Parent = handle -> Parent;
  45.     STRPTR         title        = NULL;
  46.     struct IBox    *bounds     = NULL;
  47.     LONG         extraWidth    = 0,
  48.              extraHeight    = 0;
  49.     ULONG         IDCMP        = NULL;
  50.     UWORD         align        = 0;
  51.     WORD         MinX,
  52.              MinY,
  53.              MaxX,
  54.              MaxY;
  55.     BOOL         SizeGadget    = FALSE,
  56.              SizeBRight    = FALSE,
  57.              SizeBBottom    = FALSE;
  58.     ULONG         BorderBottom,
  59.              BorderRight;
  60.     struct Menu    *LocalMenu        = NULL;
  61.     struct TagItem    *LocalMenuTags        = NULL;
  62.     struct NewMenu    *LocalMenuTemplate    = NULL;
  63.  
  64.     if(!handle)
  65.         return(NULL);
  66.  
  67.     /* ALWAYS */
  68.     {
  69.         struct TagItem *TagList = (struct TagItem *)TagParams;
  70.  
  71.         while(item = NextTagItem(&TagList))
  72.         {
  73.             switch((ULONG)item -> ti_Tag)
  74.             {
  75.                 case LAWN_MenuTemplate:
  76.  
  77.                     LocalMenuTemplate = (struct NewMenu *)item -> ti_Data;
  78.                     break;
  79.  
  80.                 case LAWN_MenuTags:
  81.  
  82.                     LocalMenuTags = (struct TagItem *)item -> ti_Data;
  83.                     break;
  84.  
  85.                 case LAWN_FlushLeft:
  86.  
  87.                     handle -> FlushLeft = item -> ti_Data;
  88.                     break;
  89.  
  90.                 case LAWN_FlushTop:
  91.  
  92.                     handle -> FlushTop = item -> ti_Data;
  93.                     break;
  94.  
  95.                 case LAWN_TitleText:
  96.  
  97.                     title = (STRPTR)item -> ti_Data;
  98.                     break;
  99.  
  100.                 case LAWN_TitleID:
  101.  
  102.                     if(!handle -> LocaleHook)
  103.                         return(NULL);
  104.                     else
  105.                         title = (STRPTR)CallHookPkt(handle -> LocaleHook,handle,(APTR)item -> ti_Data);
  106.  
  107.                     break;
  108.  
  109.                 case LAWN_Bounds:
  110.  
  111.                     bounds = (struct IBox *)item -> ti_Data;
  112.                     break;
  113.  
  114.                 case LAWN_ExtraWidth:
  115.  
  116.                     extraWidth = item -> ti_Data;
  117.                     break;
  118.  
  119.                 case LAWN_ExtraHeight:
  120.  
  121.                     extraHeight = item -> ti_Data;
  122.                     break;
  123.  
  124.                 case LAWN_IDCMP:
  125.  
  126.                     IDCMP = item -> ti_Data;
  127.                     break;
  128.  
  129.                 case LAWN_AlignWindow:
  130.  
  131.                     align = item -> ti_Data;
  132.                     break;
  133.             }
  134.         }
  135.     }
  136.  
  137. #ifdef DO_MENUS
  138.     if(LocalMenuTags)
  139.     {
  140.         if(LocalMenu = LT_NewMenuTags(LAMN_Handle,handle,TAG_MORE,LocalMenuTags))
  141.         {
  142.             menu = LocalMenu;
  143.             handle -> IDCMP |= IDCMP_MENUPICK;
  144.         }
  145.         else
  146.             return(NULL);
  147.     }
  148.     else
  149.     {
  150.         if(LocalMenuTemplate)
  151.         {
  152.             if(LocalMenu = LT_NewMenuTemplate(handle -> Screen,handle -> TextAttr,handle -> AmigaGlyph,handle -> CheckGlyph,NULL,LocalMenuTemplate))
  153.             {
  154.                 menu = LocalMenu;
  155.                 handle -> IDCMP |= IDCMP_MENUPICK;
  156.             }
  157.             else
  158.                 return(NULL);
  159.         }
  160.     }
  161. #endif    // DO_MENUS
  162.  
  163.     if(!bounds)
  164.     {
  165.         LTP_GetDisplayClip(handle -> Screen,&newBounds . Left,&newBounds . Top,&newBounds . Width,&newBounds . Height);
  166.  
  167.         bounds = &newBounds;
  168.     }
  169.  
  170.     left = handle -> Screen -> WBorLeft;
  171.  
  172.     if(title)
  173.         top = handle -> Screen -> WBorTop + handle -> Screen -> Font -> ta_YSize + 1;
  174.     else
  175.         top = handle -> Screen -> WBorTop;
  176.  
  177.     BorderRight    = handle -> Screen -> WBorRight;
  178.     BorderBottom    = handle -> Screen -> WBorBottom;
  179.  
  180.     if(handle -> ResizeView)
  181.     {
  182.         if(handle -> ResizeView -> Special . List . ResizeY)
  183.             BorderBottom = LTP_GetSizeHeight(handle);
  184.         else
  185.         {
  186.             if(handle -> ResizeView -> Special . List . ResizeX)
  187.                 BorderRight = LTP_GetSizeWidth(handle);
  188.         }
  189.     }
  190.  
  191.     OldLeft        = left;
  192.     OldRight    = BorderRight;
  193.     OldTop        = top;
  194.     OldBottom    = BorderBottom;
  195.  
  196.     if(!handle -> FlushLeft)
  197.     {
  198.         left        += handle -> InterWidth;
  199.         BorderRight    += handle -> InterWidth;
  200.     }
  201.  
  202.     if(!handle -> FlushTop)
  203.     {
  204.         top        += handle -> InterHeight;
  205.         BorderBottom    += handle -> InterHeight;
  206.     }
  207.  
  208.     LTP_CreateGadgets(handle,bounds,left,top,left + BorderRight,top + BorderBottom);
  209.  
  210.     if(handle -> Failed)
  211.         return(NULL);
  212.  
  213.         // In case the font got changed we'll have to redo it all again.
  214.         // Just to be sure, we do it all over again.
  215.  
  216.     left        = OldLeft;
  217.     BorderRight    = OldRight;
  218.     top        = OldTop;
  219.     BorderBottom    = OldBottom;
  220.  
  221.     if(!handle -> FlushLeft)
  222.     {
  223.         left        += handle -> InterWidth;
  224.         BorderRight    += handle -> InterWidth;
  225.     }
  226.  
  227.     if(!handle -> FlushTop)
  228.     {
  229.         top        += handle -> InterHeight;
  230.         BorderBottom    += handle -> InterHeight;
  231.     }
  232.  
  233.     width    = left + handle -> TopGroup -> Width + BorderRight;
  234.     height    = top + handle -> TopGroup -> Height + BorderBottom;
  235.  
  236.     if(handle -> ResizeView)
  237.     {
  238.         WORD GlyphWidth,GlyphHeight;
  239.  
  240.         MaxX = MinX = width;
  241.         MaxY = MinY = height;
  242.  
  243.         if(handle -> ResizeView -> Special . List . ResizeX)
  244.             MaxX = handle -> Screen -> Width;
  245.  
  246.         if(handle -> ResizeView -> Special . List . ResizeY)
  247.         {
  248.             MaxY = handle -> Screen -> Height;
  249.  
  250.             SizeBBottom = TRUE;
  251.         }
  252.         else
  253.             SizeBRight = TRUE;
  254.  
  255.         SizeGadget = TRUE;
  256.  
  257.         if(handle -> ResizeView -> Special . List . TextAttr)
  258.         {
  259.             GlyphWidth    = handle -> ResizeView -> Special . List . FixedGlyphWidth;
  260.             GlyphHeight    = handle -> ResizeView -> Special . List . FixedGlyphHeight;
  261.         }
  262.         else
  263.         {
  264.             GlyphWidth    = handle -> GlyphWidth;
  265.             GlyphHeight    = handle -> RPort . TxHeight;
  266.         }
  267.  
  268.         if(handle -> ResizeView -> Special . List . MinChars && handle -> ResizeView -> Special . List . MinChars < handle -> ResizeView -> Chars)
  269.             MinX -= GlyphWidth * (handle -> ResizeView -> Chars - handle -> ResizeView -> Special . List . MinChars);
  270.  
  271.         if(handle -> ResizeView -> Special . List . MinLines && handle -> ResizeView -> Special . List . MinChars < handle -> ResizeView -> Lines)
  272.             MinY -= GlyphHeight * (handle -> ResizeView -> Lines - handle -> ResizeView -> Special . List . MinLines);
  273.     }
  274.     else
  275.     {
  276.         MaxX = MinX = width;
  277.         MaxY = MinY = height;
  278.     }
  279.  
  280.     if(align & ALIGNF_LEFT)
  281.         placeLeft = 0;
  282.     else
  283.     {
  284.         if(align & ALIGNF_RIGHT)
  285.             placeLeft = bounds -> Width - (width + extraWidth);
  286.         else
  287.             placeLeft = (bounds -> Width - (width + extraWidth)) / 2;
  288.     }
  289.  
  290.     if(align & ALIGNF_TOP)
  291.         placeTop = 0;
  292.     else
  293.     {
  294.         if(align & ALIGNF_BOTTOM)
  295.             placeTop = bounds -> Height - (height + extraHeight);
  296.         else
  297.             placeTop = (bounds -> Height - (height + extraHeight)) / 2;
  298.     }
  299.  
  300.     if(align & ALIGNF_EXTRA_LEFT)
  301.         placeLeft += extraWidth;
  302.     else
  303.     {
  304.         if(!(align & ALIGNF_EXTRA_RIGHT))
  305.             placeLeft += extraWidth / 2;
  306.     }
  307.  
  308.     if(align & ALIGNF_EXTRA_TOP)
  309.         placeTop += extraHeight;
  310.     else
  311.     {
  312.         if(!(align & ALIGNF_EXTRA_BOTTOM))
  313.             placeTop += extraHeight / 2;
  314.     }
  315.  
  316.     placeLeft    += bounds -> Left;
  317.     placeTop    += bounds -> Top;
  318.  
  319.     if(placeLeft < 0)
  320.         placeLeft = 0;
  321.  
  322.     if(placeTop < 0)
  323.         placeTop = 0;
  324.  
  325.     zoom = NULL;
  326.  
  327.     handle -> AutoRefresh = TRUE;
  328. #ifdef DO_CLONING
  329.     if(handle -> CloneExtra)
  330.     {
  331.         placeLeft    = 0;
  332.         placeTop    = handle -> CloneExtra -> Screen -> BarHeight + 1;
  333.  
  334.         zoomBox . Left    = placeLeft;
  335.         zoomBox . Top    = placeTop;
  336.     }
  337. #endif    /* DO_CLONING */
  338.  
  339.     /* ALWAYS */
  340.     {
  341.         struct TagItem *TagList = (struct TagItem *)TagParams;
  342.  
  343.         while(item = NextTagItem(&TagList))
  344.         {
  345.             switch((ULONG)item -> ti_Tag)
  346.             {
  347.                 case LA_Menu:
  348.  
  349.                     if(!menu)
  350.                     {
  351.                         handle -> IDCMP |= IDCMP_MENUPICK;
  352.  
  353.                         menu = (struct Menu *)item -> ti_Data;
  354.                     }
  355.  
  356.                     break;
  357.  
  358.                 case LAWN_SmartZoom:
  359.  
  360.                     SmartZoom = item -> ti_Data;
  361.  
  362.                     if(!SmartZoom)
  363.                         break;
  364.  
  365.                 case LAWN_Zoom:
  366.  
  367.                     if(item -> ti_Data)
  368.                     {
  369.                         if(title && SmartZoom)
  370.                         {
  371.                             STATIC UWORD WhichTable[3] =
  372.                             {
  373.                                 CLOSEIMAGE,
  374.                                 ZOOMIMAGE,
  375.                                 DEPTHIMAGE
  376.                             };
  377.  
  378.                             LONG     Size = 0,i;
  379.                             BOOLEAN  GotIt = TRUE;
  380.                             UWORD     SizeType;
  381.                             Object    *Image;
  382.  
  383.                             if(handle -> Screen -> Flags & SCREENHIRES)
  384.                                 SizeType = SYSISIZE_MEDRES;
  385.                             else
  386.                                 SizeType = SYSISIZE_LOWRES;
  387.  
  388.                             for(i = 0 ; i < 3 ; i++)
  389.                             {
  390.                                 if(Image = NewObject(NULL,SYSICLASS,
  391.                                     SYSIA_Size,    SizeType,
  392.                                     SYSIA_Which,    WhichTable[i],
  393.                                     SYSIA_DrawInfo, handle -> DrawInfo,
  394.                                 TAG_DONE))
  395.                                 {
  396.                                     ULONG Width;
  397.  
  398.                                     GetAttr(IA_Width,Image,&Width);
  399.  
  400.                                     Size += Width;
  401.  
  402.                                     DisposeObject(Image);
  403.                                 }
  404.                                 else
  405.                                     GotIt = FALSE;
  406.                             }
  407.  
  408.                             if(GotIt)
  409.                             {
  410.                                 Size += 8 + TextLength(&handle -> Screen -> RastPort,title,strlen(title)) + 8;
  411.  
  412.                                 zoomBox . Width = Size;
  413.                             }
  414.                             else
  415.                                 zoomBox . Width = width;
  416.                         }
  417.                         else
  418.                             zoomBox . Width = width;
  419.  
  420.                         if(V39)
  421.                         {
  422.                             zoomBox . Left    = -1;
  423.                             zoomBox . Top    = -1;
  424.                         }
  425.                         else
  426.                         {
  427.                             zoomBox . Left    = placeLeft;
  428.                             zoomBox . Top    = placeTop;
  429.                         }
  430.  
  431.                         zoomBox . Height = handle -> Screen -> WBorTop + handle -> Screen -> Font -> ta_YSize + 1;
  432.  
  433.                         zoom = &zoomBox;
  434.                     }
  435.  
  436.                     break;
  437.  
  438.                 case LAWN_UserPort:
  439.  
  440.                     handle -> MsgPort = (struct MsgPort *)item -> ti_Data;
  441.  
  442.                     break;
  443.  
  444.                 case LAWN_HelpHook:
  445.  
  446.                     handle -> HelpHook = (struct Hook *)item -> ti_Data;
  447.  
  448.                     break;
  449.  
  450.                 case LAWN_Left:
  451.  
  452.                     placeLeft = item -> ti_Data;
  453.  
  454.                     break;
  455.  
  456.                 case LAWN_Top:
  457.  
  458.                     placeTop = item -> ti_Data;
  459.  
  460.                     break;
  461.  
  462.                 case LAWN_Parent:
  463.  
  464.                     Parent = (struct Window *)item -> ti_Data;
  465.                     break;
  466.  
  467.                 case LAWN_BlockParent:
  468.  
  469.                     BlockParent = item -> ti_Data;
  470.                     break;
  471.  
  472.                 case LAWN_BelowMouse:
  473.  
  474.                     if((placeLeft = handle -> Screen -> MouseX - (width / 2)) < 0)
  475.                         placeLeft = 0;
  476.  
  477.                     if((placeTop = handle -> Screen -> MouseY - (height / 2)) < 0)
  478.                         placeTop = 0;
  479.  
  480.                     break;
  481.  
  482.                 case LAWN_MaxPen:
  483.  
  484.                     handle -> MaxPen = (LONG)item -> ti_Data;
  485.                     break;
  486.  
  487.                 case LAWN_MoveToWindow:
  488.  
  489.                     handle -> MoveToWindow = (LONG)item -> ti_Data;
  490.                     break;
  491.  
  492.                 case LAWN_AutoRefresh:
  493.  
  494.                     handle -> AutoRefresh = (LONG)item -> ti_Data;
  495.                     break;
  496.  
  497.                 case LAWN_Show:
  498.  
  499.                     MakeVisible = item -> ti_Data;
  500.                     break;
  501.             }
  502.         }
  503.     }
  504.  
  505.     Tags = (struct TagItem *)TagParams;
  506.  
  507.     if(handle -> BackgroundPen && !V39)
  508.     {
  509.         if(NewTags = CloneTagItems(Tags))
  510.         {
  511.             STATIC Tag Filter[] = { WA_SimpleRefresh,TAG_DONE };
  512.  
  513.             FilterTagItems(NewTags,Filter,TAGFILTER_NOT);
  514.  
  515.             Tags = NewTags;
  516.         }
  517.         else
  518.         {
  519. #ifdef DO_MENUS
  520.             LT_DisposeMenu(LocalMenu);
  521. #endif    // DO_MENUS
  522.             return(NULL);
  523.         }
  524.     }
  525.  
  526.     if(Parent)
  527.     {
  528.         WORD    Left,Top,Width,Height,MoveLeft,MoveTop,
  529.             WindowLeft,WindowTop,WindowWidth,WindowHeight;
  530.  
  531.         WindowLeft    = Parent -> LeftEdge + Parent -> BorderLeft;
  532.         WindowTop    = Parent -> TopEdge + Parent -> BorderTop;
  533.         WindowWidth    = Parent -> Width - (Parent -> BorderLeft + Parent -> BorderRight);
  534.         WindowHeight    = Parent -> Height - (Parent -> BorderTop + Parent -> BorderBottom);
  535.  
  536.         LTP_GetDisplayClip(Parent -> WScreen,&Left,&Top,&Width,&Height);
  537.  
  538.         if((MoveLeft = WindowLeft + (WindowWidth - width) / 2) < 0)
  539.             MoveLeft = 0;
  540.  
  541.         if((MoveTop = WindowTop + (WindowHeight - height) / 2) < 0)
  542.             MoveTop = 0;
  543.  
  544.         if(MoveLeft < Left || MoveLeft + width > Left + Width)
  545.             MoveLeft = -1;
  546.  
  547.         if(MoveTop < Top || MoveTop + height > Top + Height)
  548.             MoveTop = -1;
  549.  
  550.         if(MoveTop != -1 && MoveLeft != -1)
  551.         {
  552.             placeLeft    = MoveLeft;
  553.             placeTop    = MoveTop;
  554.         }
  555.     }
  556.  
  557.     if(BlockParent && Parent)
  558.     {
  559.         LT_LockWindow(Parent);
  560.  
  561.         handle -> Parent = Parent;
  562.     }
  563.  
  564.     if(SizeGadget)
  565.         zoom = NULL;
  566.  
  567.     if(handle -> Window = OpenWindowTags(NULL,
  568.         WA_Left,        placeLeft,
  569.         WA_Top,         placeTop,
  570.         WA_Width,        width,
  571.         WA_Height,        height,
  572.         WA_NewLookMenus,    TRUE,
  573.         WA_CustomScreen,    handle -> Screen,
  574.         WA_MinWidth,        MinX,
  575.         WA_MinHeight,        MinY,
  576.         WA_MaxWidth,        MaxX,
  577.         WA_MaxHeight,        MaxY,
  578.         WA_SizeGadget,        SizeGadget,
  579.         WA_SizeBBottom,        SizeBBottom,
  580.         WA_SizeBRight,        SizeBRight,
  581.         WA_PointerDelay,    TRUE,
  582.         WA_BusyPointer,        TRUE,
  583.  
  584.         zoom    ? WA_Zoom :            TAG_IGNORE,    zoom,
  585.         !handle -> MsgPort ? WA_IDCMP :     TAG_IGNORE,    IDCMP_REFRESHWINDOW | IDCMP_RAWKEY | IDCMP_ACTIVEWINDOW | IDCMP_INACTIVEWINDOW | IDCMP_MOUSEBUTTONS | IDCMP_CHANGEWINDOW | IDCMP | handle -> IDCMP,
  586.         title    ? WA_Title :            TAG_IGNORE,    title,
  587.         handle -> AmigaGlyph ? WA_AmigaKey :    TAG_IGNORE,    handle -> AmigaGlyph,
  588.         handle -> CheckGlyph ? WA_Checkmark :    TAG_IGNORE,    handle -> CheckGlyph,
  589.         handle -> BackgroundPen ? WA_BackFill : TAG_IGNORE,    &handle -> BackfillHook,
  590.     TAG_MORE,Tags))
  591.     {
  592.         font = handle -> RPort . Font;
  593.  
  594.         handle -> RPort = *handle -> Window -> RPort;
  595.  
  596.         LTP_SetFont(handle,font);
  597.  
  598. #ifdef DO_BOOPSI_KIND
  599.         if(handle -> BOOPSIList)
  600.         {
  601.             AddGList(handle -> Window,(struct Gadget *)handle -> BOOPSIList,(UWORD)-1,(UWORD)-1,NULL);
  602.  
  603.             RefreshGList((struct Gadget *)handle -> BOOPSIList,handle -> Window,NULL,(UWORD)-1);
  604.         }
  605. #endif    /* DO_BOOPSI_KIND */
  606.  
  607.         AddGList(handle -> Window,handle -> List,(UWORD)-1,(UWORD)-1,NULL);
  608.  
  609.         RefreshGList(handle -> List,handle -> Window,NULL,(UWORD)-1);
  610.  
  611.         if(NewTags)
  612.         {
  613.             FreeTagItems(NewTags);
  614.  
  615.             NewTags = NULL;
  616.         }
  617.  
  618.         if(V39)
  619.         {
  620.             if(handle -> MaxPen > 0)
  621.             {
  622.                 SetMaxPen(&handle -> RPort,handle -> MaxPen);
  623.                 SetMaxPen(handle -> Window -> RPort,handle -> MaxPen);
  624.             }
  625.         }
  626.  
  627.         GT_RefreshWindow(handle -> Window,NULL);
  628.         LTP_DrawGroup(handle,handle -> TopGroup);
  629.  
  630.         LTP_MoveToWindow(handle);
  631.  
  632.         handle -> Window -> UserData = (APTR)handle;
  633.  
  634.         if(handle -> MsgPort)
  635.         {
  636.             handle -> Window -> UserPort = handle -> MsgPort;
  637.  
  638.             if(!ModifyIDCMP(handle -> Window,IDCMP_CHANGEWINDOW | IDCMP_REFRESHWINDOW | IDCMP_RAWKEY | IDCMP_INACTIVEWINDOW | IDCMP_ACTIVEWINDOW | IDCMP_MOUSEBUTTONS | IDCMP | handle -> IDCMP))
  639.             {
  640.                 handle -> Window -> UserPort = NULL;
  641.  
  642.                 return (NULL);
  643.             }
  644.         }
  645.  
  646.         if(menu)
  647.             SetMenuStrip(handle -> Window,menu);
  648.  
  649.         handle -> Menu = LocalMenu;
  650.  
  651.         handle -> Previous = NULL;
  652.  
  653.         for(i = 0 ; i < handle -> Count ; i++)
  654.         {
  655.             if(handle -> GadgetArray[i])
  656.             {
  657.                 ObjectNode *node;
  658.  
  659.                 if(GETOBJECT(handle -> GadgetArray[i],node))
  660.                 {
  661.                     if(LIKE_STRING_KIND(node) || (node -> Type == INTEGER_KIND))
  662.                     {
  663.                         if(!handle -> Previous)
  664.                             handle -> Previous = handle -> GadgetArray[i];
  665.                     }
  666.                 }
  667.             }
  668.         }
  669. #ifdef DO_CLONING
  670.         if(handle -> CloneExtra)
  671.             ScreenToFront(handle -> Window -> WScreen);
  672. #endif
  673.         if(V39)
  674.             SetWindowPointerA(handle -> Window,NULL);
  675.  
  676.         if(MakeVisible)
  677.         {
  678.             ScreenToFront(handle -> Screen);
  679.  
  680.             if(V39)
  681.             {
  682.                 WORD left,top,width,height;
  683.  
  684.                 LTP_GetDisplayClip(handle->Screen,&left,&top,&width,&height);
  685.  
  686.                 if(handle -> Window -> Width < width)
  687.                     left = (width - handle -> Window -> Width) / 2;
  688.                 else
  689.                     left = 0;
  690.  
  691.                 if(handle -> Window -> Height < height)
  692.                     top = (height - handle -> Window -> Height) / 2;
  693.                 else
  694.                     top = 0;
  695.  
  696.                 if((left = handle -> Window -> LeftEdge - left) < 0)
  697.                     left = 0;
  698.  
  699.                 if((top = handle -> Window -> TopEdge - top) < 0)
  700.                     top = 0;
  701.  
  702.                 ScreenPosition(handle -> Screen,SPOS_MAKEVISIBLE,left,top,left + width - 1,top + height - 1);
  703.             }
  704.         }
  705.  
  706.         if((handle -> Window -> Flags & WFLG_WINDOWACTIVE) && handle -> ActiveString)
  707.             LT_Activate(handle,handle -> ActiveString -> ID);
  708.     }
  709.     else
  710.     {
  711.         if(handle -> Parent)
  712.         {
  713.             LT_UnlockWindow(handle -> Parent);
  714.  
  715.             handle -> Parent = NULL;
  716.         }
  717.  
  718. #ifdef DO_MENUS
  719.         LT_DisposeMenu(LocalMenu);
  720. #endif    // DO_MENUS
  721.     }
  722.  
  723.     FreeTagItems(NewTags);
  724.  
  725.     return(handle -> Window);
  726. }
  727.  
  728.  
  729. /*****************************************************************************/
  730.  
  731.  
  732. struct Window * __stdargs
  733. LT_Layout(LayoutHandle *handle, STRPTR title,struct IBox *bounds,LONG extraWidth, LONG extraHeight,ULONG IDCMP, UBYTE align, ...)
  734. {
  735.     struct Window    *Result;
  736.     va_list      VarArgs;
  737.  
  738.     va_start(VarArgs,align);
  739.  
  740.     Result = LT_Build(handle,
  741.         LAWN_Title,        title,
  742.         LAWN_Bounds,        bounds,
  743.         LAWN_ExtraWidth,    extraWidth,
  744.         LAWN_ExtraHeight,    extraHeight,
  745.         LAWN_IDCMP,        IDCMP,
  746.         LAWN_AlignWindow,    align,
  747.     TAG_MORE,(struct TagItem *)VarArgs);
  748.  
  749.     va_end(VarArgs);
  750.  
  751.     return(Result);
  752. }
  753.  
  754.  
  755. /*****************************************************************************/
  756.  
  757.  
  758. struct Window * LIBENT
  759. LT_LayoutA(REG(a0) LayoutHandle *handle, REG(a1) STRPTR title,REG(a2) struct IBox *bounds,REG(d0) LONG extraWidth, REG(d1) LONG extraHeight,REG(d2) ULONG IDCMP, REG(d3) UBYTE align, REG(a3) struct TagItem *TagParams)
  760. {
  761.     struct Window *Result;
  762.  
  763.     Result = LT_Build(handle,
  764.         LAWN_Title,        title,
  765.         LAWN_Bounds,        bounds,
  766.         LAWN_ExtraWidth,    extraWidth,
  767.         LAWN_ExtraHeight,    extraHeight,
  768.         LAWN_IDCMP,        IDCMP,
  769.         LAWN_AlignWindow,    align,
  770.     TAG_MORE,TagParams);
  771.  
  772.     return(Result);
  773. }
  774.